package com.kaifamiao.demo.d0718;

import java.util.Scanner;

public class Ex04 {

    public static void main(String[] args) {
        // 求 5 的阶乘  5!     5! = 5 * 4 * 3 * 2 * 1

        Scanner in = new Scanner(System.in);
        System.out.println("请输入要计算阶乘的数：");
        int num = in.nextInt();
        int result = 1;

        for (int i = num; i > 1; i --){
            result = result * i;
        }

        System.out.println(num + " 的阶乘结果是: " + result);
    }
}
